package com.ch.playandroid.fragment

import android.annotation.SuppressLint
import android.widget.TextView
import androidx.fragment.app.viewModels
import com.ch.common.base.fragment.BaseFragment
import com.ch.playandroid.R
import com.ch.playandroid.databinding.FragmentProjectBinding
import com.ch.playandroid.viewmodel.ProjectViewModel

class ProjectFragment : BaseFragment<ProjectViewModel, FragmentProjectBinding>() {
    override fun getLayoutResID(): Int {
        return R.layout.fragment_project
    }

    @SuppressLint("NewApi")
    override fun initView() {
        mBinding.flowLayout.addView(getTextView("学习Android"))
        mBinding.flowLayout.addView(getTextView("Kotlin知识之旅"))
        mBinding.flowLayout.addView(getTextView("C++让你运行速度成倍提高"))

    }

    @SuppressLint("NewApi", "WrongConstant", "ResourceAsColor")
    fun getTextView(str:String): TextView {
        return TextView(mContext).run {
            text = str
            setTextAppearance(R.style.ItemStyle)
            setBackgroundResource(R.color.teal_700)
            setPadding(12,5,12,5)
            this
        };
    }

    override fun initObserve() {
    }

    override val viewModel: ProjectViewModel by viewModels()
    override fun bindViewModel() {
    }
}